package com.zzyl.service.impl;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.zzyl.base.PageResponse;
import com.zzyl.dto.NursingPlanDto;
import com.zzyl.entity.NursingPlan;
import com.zzyl.mapper.NursingPlanMapper;
import com.zzyl.service.NursingPlanService;
import com.zzyl.vo.NursingPlanVo;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class NursingPlanServiceImpl implements NursingPlanService {

    @Autowired
    private NursingPlanMapper nursingPlanMapper;

    //分页查询
//    @Override
//    public PageResponse<NursingPlanVo> getByPage(String name, Integer status, Integer pageNum, Integer pageSize) {
//        PageHelper.startPage(pageNum, pageSize);
//        Page<NursingPlan> nursingPlans = nursingPlanMapper.selectByPage(name, status);
//        PageResponse<NursingPlanVo> nursingPlanVoPageResponse = PageResponse.of(nursingPlans, NursingPlanVo.class);
//        return nursingPlanVoPageResponse;
//    }
    //分页查询
    @Override
    public PageResponse<NursingPlanVo> selectByPage(Integer pageNum, Integer pageSize, String planNo, String elderName, Integer status, Long startTime, Long endTime) {
        PageHelper.startPage(pageNum, pageSize);
        Page<NursingPlan> nursingPlans = nursingPlanMapper.selectByPage(null,planNo, elderName, status, startTime, endTime);
//        PageResponse<NursingPlanVo> nursingPlanVoPageResponse = PageResponse.of(nursingPlans, NursingPlanVo.class);
        return PageResponse.of(nursingPlans, NursingPlanVo.class);
    }
    //新增计划
    @Override
    public void addNursingPlan(NursingPlanDto nursingPlanDto) {
        nursingPlanMapper.addNursingPlan(nursingPlanDto);
    }
}
